/**
* The InputReader Class only the text input from the command line from the client.
* Group: Y1
* @author Mason Kwiat
*/


package lightspeed.Network;
import java.util.Scanner;

public class InputReader extends Thread
{
	/**
	*	Clientpacket object who message will get set according to the user's input.
	*/
	ClientPacket cpack;
	/**
	*	Constructor: creates an instance of InputReader
	*	@param cp ClientPacket object
	*/
	public InputReader(ClientPacket cp)
	{
		cpack = cp;
	}
	/**
	*	Opens up the scanner instream in order to read input from the user. If the user's input is not a NULL string,
	*	then that string gets set as the message that the ClientPacket object holds. Also if the user inputs "quit",
	*  	then the method prints out an error message.
	*/
	public void run()
	{
		boolean connected = true;
		
		Scanner stdIn = new Scanner(System.in);
		
		while(connected)
        {
		    
            String fromUser = stdIn.nextLine();
	    	if (fromUser != null)
	    	{
				cpack.setMessage(fromUser);
//				System.out.println("message recorded");
	    	}
	    	else if(fromUser.equals("/quit"))
	    	{
	    		System.out.println("wtf??????");
	    		break;
	    	}
        }
	}
}